home *** CD-ROM | disk | FTP | other *** search
/ Programmers Heaven 2 / Programmers Heaven 2.iso / files / graphics / library / wgt51_r2.zip / WGT5 / EXAMPLES / WGT24.C < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-03  |  4.0 KB  |  113 lines

  1. /*
  2. ==============================================================================
  3.                       WordUp Graphics Toolkit Version 5.0                     
  4.                              Demonstration Program 24                         
  5.                                                                               
  6.  Display special effects using wwipe command.                                
  7.                                                                               
  8.  *** PROJECT ***                                                             
  9.  This program requires the file WGT5_WC.LIB to be linked.                    
  10.                                                                               
  11.  *** DATA FILES ***                                                          
  12.  Make sure that you have WGT2.PCX in your executable directory. 
  13.                                                            WATCOM C++ VERSION 
  14. ==============================================================================
  15. */
  16.  
  17. #include <conio.h>
  18. #include <stdio.h>
  19. #include <wgt5.h>
  20.  
  21.  
  22. void main(void)
  23. {
  24.   block screen1, screen2;                /* Two virtual screens */
  25.   color palette[256];                    /* Our palette */
  26.   short i, j;                            /* Loop counters */
  27.   short oldmode;                         /* Stores initial video mode */
  28.  
  29.   if ( !vgadetected () )
  30.   {
  31.     printf("Error - VGA card required for any WGT program.\n");
  32.     exit (0);
  33.   }
  34.   printf ("WGT Example #24\n\n");
  35.   printf ("The WWIPE command is used to show several different screen wipes.\n");
  36.   printf ("Using WRETRACE keeps the speed constant on all computers. Try removing\n");
  37.   printf ("all retraces to obtain maximum speed and notice the difference.\n");
  38.   printf ("A keypress advances to the next wipe at each point.\n");
  39.   printf ("\n\nPress any key to continue.\n");
  40.   getch ();
  41.  
  42.   oldmode = wgetmode ();                /* Preserve initial video mode */
  43.   vga256 ();                            /* Initialize graphics mode */
  44.  
  45.   screen1 = wloadpcx ("wgt2.pcx", palette);  /* Load image file from disk */
  46.   wtextcolor (15);                      /* Use index 15 for text */
  47.  
  48.   /* Note: This text will be on our second screen - used for wipes */
  49.   wouttextxy (0, 0, NULL, "SCREEN BUFFER #2");
  50.   wouttextxy (0, 50, NULL, "This screen is one of our 2 screens");
  51.   wouttextxy (0, 58, NULL, "used to perform the wipe effect.");
  52.   wouttextxy (46, 100, NULL, "Press a key to perform wipe");
  53.  
  54.   screen2 = wnewblock (0, 0, 319, 199); /* Allocate memory for screen2 */
  55.   wnormscreen ();                       /* Make sure we're drawing on default screen */
  56.   wsetpalette (0, 255, palette);        /* Now use the palette */
  57.  
  58.   getch ();                             /* Get a keypress */
  59.  
  60.   for (i = 0; i < 200; i++)
  61.   {
  62.     wwipe (0, 0, 319, i, screen1);           /* Wipe screen down from right */
  63.     wwipe (319, 199, 0, 199 - i, screen1);   /* Wipe screen up from left */
  64.     wretrace ();
  65.   }
  66.   getch ();
  67.  
  68.  
  69.   /* Now wipe on the black screen using horizontal lines meeting at middle */
  70.   for (i = 0; i < 100; i++)
  71.   {
  72.     wwipe (0, i, 319, i, screen2);
  73.     wwipe (0, 199 - i, 319, 199 - i, screen2);
  74.     wretrace ();
  75.   }
  76.   getch ();
  77.  
  78.   /* Now perform a "circular" wipe, by going around the screen from center */
  79.   for (i = 0; i < 320; i++)
  80.    {
  81.     wwipe (159, 99, i, 0, screen1);
  82.     wretrace ();
  83.    }
  84.   for (i = 0; i < 200; i++)
  85.    {
  86.     wwipe (159, 99, 319, i, screen1);
  87.     wretrace ();
  88.    }
  89.   for (i = 319; i >= 0; i--)
  90.    {
  91.     wwipe (159, 99, i, 199, screen1);
  92.     wretrace ();
  93.    }
  94.   for (i = 199; i >= 0; i--)
  95.    {
  96.     wwipe (159, 99, 0, i, screen1);
  97.     wretrace ();
  98.    }
  99.   getch ();
  100.  
  101.   /* Clear with black screen by wiping top to bottom */
  102.   for (i = 0; i < 200; i++)
  103.    {
  104.     wwipe (0, i, 319, i, screen2);
  105.     wretrace ();
  106.    }
  107.   getch ();
  108.  
  109.   wfreeblock (screen1);          /* Remember to free that memory */
  110.   wfreeblock (screen2);
  111.   wsetmode (oldmode);            /* Restore initial video mode */
  112. }
  113.